package com.ebring.shareEducation.controller;

import com.ebring.shareEducation.bean.Questions;
import com.ebring.shareEducation.service.QuestionsService;
import com.ebring.shareEducation.utils.RspMsg;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin(origins = "http://wangliang.vipgz1.idcfengye.com", maxAge = 3600)
public class QuestionController {

    @Autowired
    private QuestionsService questionsService;



    /**
     * 查找所有客诉
     *
     * @param
     * @return
     */
    @GetMapping("/question/selectquestion")
    @ApiOperation(value="查找所有客诉", notes="查找所有客诉")
    public RspMsg<Questions> selectQuestionsfind() {
        return questionsService.selectQuestions();
    }








    /**
     * 模糊时查询

     * @param questions
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/questions/findquestions")
    @ApiOperation(value="模糊时查询客诉", notes="模糊时查询客诉")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name = "Questions", value = "客诉问题对象", required = true, dataType = "Questions"),
            @ApiImplicitParam(paramType="query",name = "pageNum", value = "页数", required = true, dataType = "Integer"),
            @ApiImplicitParam(paramType="query",name = "pageSize", value = "总页数", required = true, dataType = "Integer")

            })
    public RspMsg<List<Questions>> findTrade(Questions questions, Integer pageNum, Integer pageSize) {

        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        PageHelper.startPage(pageNum, pageSize);
        return questionsService.findQuestions(questions);
    }


}
